import React from "react";
import { Navigate } from "react-router-dom";

type RouteProps = {
    children?: React.ReactNode;
};

const AuthRoute: React.FC<RouteProps> = (props) => {
    // children 为子组件
    const { children } = props;
    // 判断是否有token
    const token = localStorage.getItem("token");
    
    if (token) {
        return <>{ children }</>
    } else {
        return <Navigate to="/home/index"></Navigate>;
        // navigateTo("/home/index");
    }
};
export default AuthRoute;
